<template>
  <div class="header">
    <div class="collapse-btn">
      <i class="el-icon-service" type="primary"></i>
    </div>
    <div class="log">
      Music 后台管理
    </div>
    <div class="header-right">
      <div class="user-avator">
        <el-avatar :size="60">
          <img src="../assets/img/123.jpg" />
        </el-avatar>
      </div>
      <el-dropdown trigger="click" @command="handleCommand" class="user-name">
        <span class="el-dropdown-link">
          {{userName}}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
  export default {
    computed: {
      userName() {
        return localStorage.getItem('userName');
      }
    },
    methods: {
      handleCommand(command) {
        if (command === 'logout')
          console.log(123);
      },
    }
  }
</script>

<style>
  .header {
    position: relative;
    color: #9966CC;
    width: 100%;
  }

  .collapse-btn {
    padding: 0 20px;
    height: 100%;
    line-height: 75px;
    float: left;
    font-size: 30px;
  }

  .log {
    font-size: 20px;
    height: 100%;
    color: #9966CC;
    float: left;
    line-height: 75px;
  }

  .header-right {
    float: right;
    height: 75px;
    width: 165px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin: 0px 20px 0px 0px;
  }

  .el-dropdown-link {
    cursor: pointer;
    font-size: 20px;
    color: #000000;
  }
</style>
